/**
 * Copyright (C) 2011 Audit Logger Project. All rights reserved.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.auditlogger.config;

import org.auditlogger.config.providers.DefaultPluginConfigurator;
import org.auditlogger.config.spi.PluginConfigurator;
import org.auditlogger.config.spi.PropertiesConfigurator;
import org.auditlogger.config.util.ConfigurationException;

public class ConfigurationServices {
	
	private static PropertiesConfigurator propertiesConfigurator = null;
	private static PluginConfigurator pluginConfigurator = null;
	
	// prevents instantiation
	private ConfigurationServices() {
	}
	
	 // Service access API
    public synchronized static PropertiesConfigurator getPropertiesConfigurator() 
                       throws ConfigurationException {
    	if (propertiesConfigurator == null) {
    		propertiesConfigurator =  getPluginConfigurator().getStaticConfigurationProvider();
    	}
        return propertiesConfigurator;
    }
    
    public synchronized static PluginConfigurator getPluginConfigurator () {
    	if (pluginConfigurator == null) {
    		pluginConfigurator = new DefaultPluginConfigurator();
    	}
    	return pluginConfigurator;
    }
    
    public synchronized static void registerDefaultProvider(PropertiesConfigurator p) {
    	propertiesConfigurator = p;
    }
}
